from SQLiteManager import SQLiteManager

from ModelWishList import ModelWishList
from ModelCollectList import ModelCollectList
from ModelTodo import ModelTodo
from ModelRecord import ModelRecord
from ModelTypeList import ModelTypeList


class DataManager():
    """
    this class manages all the data
    """

    _initialized = 0
    
    @classmethod
    def init(cls, name):
        if cls._initialized == 1:
            return

        #wish list part
        cls.db = SQLiteManager(name)
        cls.wishlist = ModelWishList()
        cls.collectlist = ModelCollectList()
        cls.todolist = ModelTodo()
        cls.record = ModelRecord()
        cls.types = ModelTypeList()

    @classmethod
    def change_db(cls, path):
        cls.db = SQLiteManager(path)
        cls.wishlist = ModelWishList()
        cls.collectlist = ModelCollectList()
        cls.todolist = ModelTodo()
        cls.record = ModelRecord()
        cls.types = ModelTypeList()

        #we should also send out message to refresh ui
        cls.wishlist.refresh()
        cls.collectlist.refresh()
        cls.todolist.refresh()
        cls.record.refresh()
